package com.turing.data.engine.utils;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;

/**
 * @ClassName regexUtil
 * @Description: TODO
 * @Author: fz
 * @Date 2020/12/3
 * @Version V1.0
 **/
public class QJwlTableFilterUtil {

    //无效表头
    public static Boolean IneffectiveTableHeaderAlias(String tableHeader) {


        if (tableHeader.contains("注释")) {

            return true;
        }

        if (tableHeader.contains("序号")) {

            return true;
        }

        if (tableHeader.contains("行次")) {

            return true;
        }

        if (tableHeader.contains("附注")) {

            return true;
        }

        if (tableHeader.contains("注降")) {

            return true;
        }

        return false;
    }

    //有效表头
    static boolean TableHeaderAlias(String tableHeader) {

        if (tableHeader.contains("项目")) {

            return true;
        }

        if (tableHeader.contains("项参目")) {

            return true;
        }

        if (tableHeader.contains("科目")) {

            return true;
        }

        if (tableHeader.contains("项E")) {

            return true;
        }

        if (tableHeader.contains("项")) {

            return true;
        }

        if (tableHeader.contains("顶目")) {

            return true;
        }

        return false;
    }

    //识别表头
    static boolean DistinguishTableHeader(String tableHeader) {

        if (tableHeader.contains("项目:")) {

            return true;
        }

        if (tableHeader.contains("项参目:")) {

            return true;
        }

        if (tableHeader.contains("科目:")) {

            return true;
        }

        if (tableHeader.contains("项E:")) {

            return true;
        }

        if (tableHeader.startsWith("项:")) {

            return true;
        }

        if (tableHeader.contains("顶目:")) {

            return true;
        }

        return false;
    }

    //识别表名
    static Integer TableNameAlias(String tableName) {

        if (tableName.contains("资产负债表")) {

            return 1;
        }

        if (tableName.contains("利润表")) {

            return 2;
        }

        if (tableName.contains("现金流量表") || tableName.contains("现流表")) {

            return 3;
        }

        return 0;
    }

    //获取表头有效的索引： 项目:序号:年末余额:项目:序号:年末余额   转换成 项目:年末余额:项目:年末余额
    static Map<Integer, Integer> getHeaderEffectiveIndex(LinkedList<String> tableHeaderList) {

        Integer effectiveKey = null;
        Integer effectiveValue = null;
        Map<Integer, Integer> map = new HashMap<>();

        for (int i = 0; i < tableHeaderList.size(); i++) {

            String tableHeader = tableHeaderList.get(i);

            if (TableHeaderAlias(tableHeader)) {
                effectiveKey = i;
                continue;
            }
            if (null != effectiveKey) {

                if (!IneffectiveTableHeaderAlias(tableHeader) && !TableHeaderAlias(tableHeader)) {

                    effectiveValue = i;
                    map.put(effectiveKey, effectiveValue);
                    effectiveKey = null;
                }
            }

        }

        return map;
    }

    //获取元素后面集合的有效索引
    static Integer getEffectiveIndex(LinkedList<String> list, int l) {

        Integer index = 0;
        if (l + 1 < list.size()) {

        }


        return -1;
    }


}
